package cn.demoncat.util.mysql.entity;

import java.util.List;

/**
 * Mysql表
 *
 * @author 延晓磊
 * @since 2020年10月10日
 */
public class MysqlTable {

    // 名称
    private String name;
    // 注释
    private String comment;
    // 引擎
    private String engine;
    // 创建时间
    private String createTime;

    // 字段集
    private List<MysqlColumn> columns;
    // ID字段
    private MysqlColumn idColumn;

    public MysqlTable(String name, String comment, String engine, String createTime) {
        this.name = name;
        this.comment = comment;
        this.engine = engine;
        this.createTime = createTime;
    }

    public MysqlTable() {
        super();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getEngine() {
        return engine;
    }

    public void setEngine(String engine) {
        this.engine = engine;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public List<MysqlColumn> getColumns() {
        return columns;
    }

    /**
     * 设置字段
     * @param columns
     */
    public void setColumns(List<MysqlColumn> columns) {
        // 所有字段
        this.columns = columns;
        for (MysqlColumn column : columns) {
            if (column.getName().equals("id")) {
                // id字段
                this.idColumn = column;
                break;
            }
        }
    }

    public MysqlColumn getIdColumn() {
        return idColumn;
    }

    public void setIdColumn(MysqlColumn idColumn) {
        this.idColumn = idColumn;
    }
}
